var _o76;
var cc__decorate = __decorate;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var cc__decorator = cc._decorator;
var ccp_ccclass = cc__decorator.ccclass;
var ccp_property = cc__decorator.property;
var def_PoolManager = _o76 = /* */function () {
  function _ctor() {
    babel_classCallCheck(this, _ctor);
    this.res = [];
    this.pools = new Map();
  }
  return babel_createClass(_ctor, [{
    key: "get",
    value: function get(e) {
      var t = this.pools.get(e.name);
      if (!t) {
        t = new cc.NodePool();
        this.pools.set(e.name, t);
      }
      if (t.size() > 0) {
        return t.get();
      } else {
        return cc.instantiate(e);
      }
    }
  }, {
    key: "getNodeByName",
    value: function getNodeByName(e) {
      var _this66 = this;
      var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
      return new Promise(function (n, _o77) {
        if (_this66.hasPool(e)) {
          n(_this66.pools.get(e).get());
        } else {
          cc.loader.loadRes(t, cc.Prefab, function (e, t) {
            if (e) {
              _o77(e);
            } else {
              n(_this66.get(t));
            }
          });
        }
      });
    }
  }, {
    key: "hasPool",
    value: function hasPool(e) {
      var t = this.pools.get(e);
      return !!t && t.size() > 0;
    }
  }, {
    key: "put",
    value: function put(e, t) {
      var n = t || e.name;
      var _o78 = this.pools.get(n);
      if (!_o78) {
        _o78 = new cc.NodePool();
        this.pools.set(n, _o78);
      }
      _o78.put(e);
    }
  }, {
    key: "putAllChildren",
    value: function putAllChildren(e) {
      for (var _t37 = 0; _t37 < e.childrenCount;) {
        var _n37 = e.children[_t37];
        _n37.removeFromParent();
        this.put(_n37);
      }
    }
  }, {
    key: "clear",
    value: function clear(e) {
      var t = this.pools.get(e.name);
      if (!t) {
        t = new cc.NodePool();
        this.pools.set(e.name, t);
      }
      t.clear();
    }
  }], [{
    key: "getInstance",
    value: function getInstance() {
      this._instance || (this._instance = new _o76());
      return this._instance;
    }
  }]);
}();
def_PoolManager._instance = null;
def_PoolManager = _o76 = cc__decorate([ccp_ccclass], def_PoolManager);
exports.default = def_PoolManager;